home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / system / interc2.zip / INTERCEP.DOC < prev    next >
Text File  |  1987-08-02  |  7KB  |  153 lines

  1. INTERCEPT/INTERPRET -- monitor DOS and BIOS calls. By:
  2.  
  3.     Ned Konz
  4.     210 Oleeta St.
  5.     Ormond Bch, FL 32074
  6.     BIX:nkonz  CIS:76046,223  (904)672-2431
  7.     08/02/1987
  8.  
  9. ============================================================
  10. Program description:
  11. ============================================================
  12. INTERCEPT (intercep.exe) and INTERPRET (interpre.exe)
  13. were written so I could monitor the interaction between
  14. unknown programs and MS-DOS (and the BIOS). I've used them
  15. to help disassemble and patch programs, as well as to 
  16. debug my own programs.
  17.  
  18. I'll give a short example of how you run INTERCEPT here.
  19. I'm not going to explain what the DOS or BIOS are, or why
  20. anyone should care what a program does with them. If you
  21. don't know, you probably don't need this program. But if
  22. you want to learn about the IBM-PC or MS-DOS, INTERCEPT
  23. makes a good learning tool along with a good book on DOS
  24. (like Peter Norton's "Programmer's Guide to the IBM PC".)
  25.  
  26. Suppose you were curious about what the DOS utility
  27. "LABEL.COM" does. Run INTERCEPT like this (assuming you've
  28. installed it properly; see a later section of this file):
  29.  
  30.     intercept label
  31.  
  32. You'll see a logo from INTERCEPT appear, followed by
  33. the normal operation of LABEL. Answer its question, and
  34. it ends. At this point, INTERCEPT runs INTERPRET and
  35. a file called "intercep.out" is produced in the current
  36. directory.
  37.  
  38. INTERCEP.OUT looks like this:
  39.  
  40. INTERCEPT/INTERPRET by Ned Konz 08/02/87
  41. dump of DOS/BIOS calls from program "label"
  42. 595A:0597  2130   Get DOS version number
  43. 595A:05BD  2119   Report current drive
  44. 595A:05CC  21 4409  0003 0000 595a  595a 595a 0100 fffe 0882
  45. 595A:05E8  211a   Set DTA to 595A:0316
  46. 595A:05EF  2111   Search for first file matching FCB at 595A:0316
  47. 595A:09F5  2140   Write 0014 bytes from 595A:07E0 to file #0002 
  48. 595A:09F5  2140   Write 0010 bytes from 595A:07E0 to file #0002 
  49. 595A:09F5  2140   Write 0014 bytes from 595A:07E0 to file #0002 
  50. 595A:09F5  2140   Write 0014 bytes from 595A:07E0 to file #0002 
  51. 595A:09F5  2140   Write 0008 bytes from 595A:07E0 to file #0002 
  52. 595A:0714  213f   Read 007F bytes from file #0000 to 595A:0081
  53. 595A:09F5  2140   Write 0002 bytes from 595A:07E0 to file #0002 
  54. 595A:0778  2113   Delete file using FCB at 595A:0343
  55. 595A:078A  215b   Create new file (name at 595A:0304, attr. 08)
  56. 595A:0792  213e   Close file handle #0006
  57. 595A:0592  214c   Terminate process (return code 00)
  58.  
  59. What the lines mean is this:
  60.  
  61. * The first field (like "595A:0597") is the program counter address
  62. from which the DOS or BIOS interrupts were called.
  63.  
  64. * The second field (like "2130") is the interrupt (here 21h, the
  65. DOS catchall interrupt) and (possibly) the AH or AX values
  66. (the 30 here means that AH equaled 30h -- the function code
  67. for "get DOS version number", and AL (the other half of the
  68. A register called AX) was unimportant.
  69.  
  70. * The rest of the line is a description of what that INTerrupt
  71. call means in the context of MS-DOS or the IBM-PC BIOS, as defined
  72. in the INTERPRE.DAT file. You can change this file if you need to,
  73. to correct it or add other definitions.
  74.  
  75. In other words, if you used DEBUG to look at LABEL.COM around offset 0597,
  76. you'd see:
  77.  
  78. 3F24:058E B44C           MOV    AH,4C
  79. 3F24:0590 B000           MOV    AL,00
  80. 3F24:0592 CD21           INT    21
  81. 3F24:0594 50             PUSH    AX
  82. 3F24:0595 B430           MOV    AH,30
  83. 3F24:0597 CD21           INT    21
  84. 3F24:0599 3D0314         CMP    AX,1403
  85. 3F24:059C 740A           JZ    05A8 
  86.  
  87. Note that there are two INT 21 instructions in this short segment.
  88. The one at offset 0592 corresponds to the last line in INTERCEP.OUT:
  89.     595A:0592  214c   Terminate process (return code 00)
  90. and the one at offset 0597 corresponds to the first line:
  91.     595A:0597  2130   Get DOS version number
  92. Note also that the segment values here (3F24:) are different
  93. than in INTERCEP.OUT. This is because both DEBUG and INTERCEPT
  94. ran LABEL.COM as a "child process", and they're different
  95. sizes.
  96.  
  97. What about the line that reads:
  98.     595A:05CC  21 4409  0003 0000 595a  595a 595a 0100 fffe 0882
  99. Well, that's one of those "RESERVED", undocumented DOS calls
  100. which is used frequently by the DOS utilities. I've documented
  101. some of these, like INT 21h, function 37h, sub-functions 01 and 02,
  102. which get and set the DOS parameter switch character (and
  103. are called by the undocumented Turbo C routines getswitchar() and
  104. setswitchar().)
  105.  
  106. You can run INTERCEPT as "intercep -L" and get a long-form
  107. output, with the values of all the registers at each call.
  108.  
  109. ============================================================
  110. INSTALLING INTERCEPT:
  111. ============================================================
  112. INTERCEPT is supplied as an ARC file. If you're reading
  113. this, you've figured out how to take apart an ARC file.
  114. Just move the following files to a directory that's
  115. somewhere on your PATH:
  116.     INTERCEP.EXE    -- The INTERCEPT program itself
  117.     INTERPRE.EXE    -- The INTERPRET program
  118.     INTERPRE.DAT    -- The definition of all the interrupts
  119. The rest of the files here are either documentation
  120. or C source text, and aren't necessary to operation of the
  121. program. If you run INTERCEPT without any command-line
  122. arguments, you can get a usage prompt. (see below)
  123.  
  124. ============================================================
  125. Contents of ARC file:
  126. ============================================================
  127. Filename        Length   Method     Size   Ratio    Date      Time
  128. --------        ------   ------    ------  -----    ----      ----
  129. INTERCEP.C       11197  Crunched     5798   49%   08-02-87  18:35:42
  130. INTERCEP.DOC      6896  Crunched     3731   46%   08-02-87  19:32:38
  131. INTERCEP.EXE     16400  Crunched    12612   24%   08-02-87  18:41:20
  132. INTERCEP.H        1232  Crunched      802   35%   08-02-87  15:03:42
  133. INTERPRE.C        6291  Crunched     3315   48%   08-02-87  18:37:52
  134. INTERPRE.DAT      7435  Crunched     3960   47%   08-02-87  18:50:22
  135. INTERPRE.EXE     32464  Crunched     8704   74%   08-02-87  18:41:22
  136. ----            ------             ------  -----
  137. 0007             81915              38922   53%
  138.  
  139. ============================================================
  140. INTERCEPT: Usage:
  141. ============================================================
  142. intercept [-l] [-T tmpdir] [-s maxcalls] [-o outfile] program [args[...]]
  143.     -l    sets long format output: explanation AND register values
  144.     -T    sets temporary directory for intermediate file to "tmpdir"
  145.         (will use TMP or TMPDIR environment vars. if found otherwise)
  146.     -s    sets the maximum number of SWI records to "maxcalls"
  147.     -o    names the output filename to "outfile" rather than
  148.         the default name ("intercep.out")
  149.     program        is the name of the program to monitor
  150.     args        are any command-line arguments to be passed
  151.             to the monitored program.
  152. ============================================================
  153.